home *** CD-ROM | disk | FTP | other *** search
/ Workbench Add-On / Workbench Add-On - Volume 1.iso / BBS-Archive / Comm / AmiTCP30b2.lha / src / netlib / perror.c < prev    next >
C/C++ Source or Header  |  1994-02-03  |  2KB  |  63 lines

  1. RCS_ID_C = "$Id: perror.c,v 3.1 1994/02/03 19:22:51 ppessi Exp $";
  2. /*
  3.  * perror.c -- print error message
  4.  *
  5.  * Author: ppessi <Pekka.Pessi@hut.fi>
  6.  *
  7.  * Copyright © 1993 AmiTCP/IP Group, <AmiTCP-Group@hut.fi>
  8.  *                  Helsinki University of Technology, Finland.
  9.  *
  10.  * Created      : Sat Mar 20 02:10:14 1993 ppessi
  11.  * Last modified: Thu Feb  3 12:57:11 1994 ppessi
  12.  *
  13.  */
  14.  
  15. /****** net.lib/perror *******************************************************
  16.  
  17.     NAME
  18.         perror - socket error messages
  19.  
  20.     SYNOPSIS
  21.         extern int errno;
  22.  
  23.         #include <stdio.h>
  24.  
  25.         perror(banner)
  26.         void perror(const char *)
  27.  
  28.     FUNCTION
  29.         The perror() function finds the error message corresponding to the
  30.         current value of the global variable errno and writes it, followed
  31.         by a newline, to the stderr. If the argument string is non-NULL it
  32.         is preappended to the message string and separated from it by a
  33.         colon and space (`: '). If string is NULL only the error message
  34.         string is printed.
  35.  
  36.     NOTES
  37.         The perror() function requires the stdio functions to be linked.
  38.  
  39.     SEE ALSO
  40.         strerror(), PrintNetFault(), <netinclude:sys/errno.h>
  41.  
  42. ******************************************************************************
  43. */
  44.  
  45. #include <stdio.h>
  46. #include <errno.h>
  47. #include <string.h>
  48. #include <clib/netlib_protos.h>
  49.  
  50. void 
  51. perror(const char *banner)
  52. {
  53.   const char *err = strerror(errno);
  54.  
  55.   if (banner != NULL) {
  56.     fputs(banner, stderr);
  57.     fputs(": ", stderr);
  58.   }
  59.   fputs(err, stderr);
  60.   fputc('\n', stderr);
  61.   fflush(stderr);
  62. }
  63.